#include <stdio.h>
#include "Definitions.h"
#include "Simulator.h"
#include "Outports.h"
#include "Inports.h"
#include "Controllers.h"
#include "Signals.h"
#include "Registers.h"
#include "Tracers.h"
#include "Displays.h"
#include "OutportDynamicList.h"

using namespace std;














void Signal_paddle_new_location_y::Evaluate(void)
{
      switch(Simulator::controller_ctrl_paddle->CurrentControlStep)
      {
      case 0:
    Simulator::signal_paddle_abs_distance_y->Evaluate();
    if (Simulator::signal_paddle_abs_distance_y->Value->GreaterThan(this->Constant_5))
    {
        this->Value_binaryexpression48 = Integer::One;
    }
    else
    {
        this->Value_binaryexpression48 = Integer::Zero;
    }
    Simulator::signal_paddle_sign_distance_y->Evaluate();
    if (Simulator::signal_paddle_sign_distance_y->Value->GreaterThan(this->Constant_0))
    {
        this->Value_binaryexpression51 = Integer::One;
    }
    else
    {
        this->Value_binaryexpression51 = Integer::Zero;
    }
    if (Integer::Zero->NotEquals(this->Value_binaryexpression51))
    {
        this->Value_ternaryexpression55->ValueCopy(this->Constant_5);
    }
    else
    {
        this->Value_ternaryexpression55->ValueCopy(this->Constant_minus_5);
    }
    Integer::Add(&(this->Value_binaryexpression57), this->Value_ternaryexpression55, Simulator::register_paddle_location_y->StoredValue);
    Simulator::signal_paddle_distance_y->Evaluate();
    Integer::Add(&(this->Value_binaryexpression60), Simulator::signal_paddle_distance_y->Value, Simulator::register_paddle_location_y->StoredValue);
    if (Integer::Zero->NotEquals(this->Value_binaryexpression48))
    {
        this->Value_ternaryexpression61->ValueCopy(this->Value_binaryexpression57);
    }
    else
    {
        this->Value_ternaryexpression61->ValueCopy(this->Value_binaryexpression60);
    }
    this->Value->ValueCopy(this->Value_ternaryexpression61);
        break;
      }

    /* Mark this entity as valid for this cycle  */
    this->Cycle = Simulator::CurrentCycle;
}

void Signal_paddle_new_location_y::Initialize(void)
{
    this->Value = new Integer(16, true);
    this->Constant_5 = new Integer(3, "5", false);
    this->Value_binaryexpression48 = new Integer(1, false);
    this->Constant_0 = new Integer(2, false);
    this->Value_binaryexpression51 = new Integer(1, false);
    this->Constant_minus_5 = new Integer(4, "-5", true);
    this->Value_ternaryexpression55 = new Integer(4, true);
    this->Value_binaryexpression57 = new Integer(16, true);
    this->Value_binaryexpression60 = new Integer(16, true);
    this->Value_ternaryexpression61 = new Integer(16, true);
}






void Signal_paddle_distance_y::Evaluate(void)
{
      switch(Simulator::controller_ctrl_paddle->CurrentControlStep)
      {
      case 0:
    Debug::Assert(Simulator::outPort_test_paddle_ball_y->Cycle == Simulator::CurrentCycle);
    Integer::Subtract(&(this->Value_binaryexpression25), Simulator::outPort_test_paddle_ball_y->Value, Simulator::register_paddle_location_y->StoredValue);
    this->Value->ValueCopy(this->Value_binaryexpression25);
        break;
      }

    /* Mark this entity as valid for this cycle  */
    this->Cycle = Simulator::CurrentCycle;
}

void Signal_paddle_distance_y::Initialize(void)
{
    this->Value = new Integer(16, true);
    this->Value_binaryexpression25 = new Integer(16, true);
}








void Signal_paddle_abs_distance_y::Evaluate(void)
{
      switch(Simulator::controller_ctrl_paddle->CurrentControlStep)
      {
      case 0:
    Debug::Assert(Simulator::outPort_test_paddle_ball_y->Cycle == Simulator::CurrentCycle);
    if (Simulator::outPort_test_paddle_ball_y->Value->LessThan(Simulator::register_paddle_location_y->StoredValue))
    {
        this->Value_binaryexpression39 = Integer::One;
    }
    else
    {
        this->Value_binaryexpression39 = Integer::Zero;
    }
    Simulator::signal_paddle_distance_y->Evaluate();
    Integer::Negate(&(this->Value_unaryexpression41), Simulator::signal_paddle_distance_y->Value);
    Simulator::signal_paddle_distance_y->Evaluate();
    if (Integer::Zero->NotEquals(this->Value_binaryexpression39))
    {
        this->Value_ternaryexpression43->ValueCopy(this->Value_unaryexpression41);
    }
    else
    {
        this->Value_ternaryexpression43->ValueCopy(Simulator::signal_paddle_distance_y->Value);
    }
    this->Value->ValueCopy(this->Value_ternaryexpression43);
        break;
      }

    /* Mark this entity as valid for this cycle  */
    this->Cycle = Simulator::CurrentCycle;
}

void Signal_paddle_abs_distance_y::Initialize(void)
{
    this->Value = new Integer(16, true);
    this->Value_binaryexpression39 = new Integer(1, false);
    this->Value_unaryexpression41 = new Integer(16, true);
    this->Value_ternaryexpression43 = new Integer(16, true);
}









void Signal_paddle_sign_distance_y::Evaluate(void)
{
      switch(Simulator::controller_ctrl_paddle->CurrentControlStep)
      {
      case 0:
    Debug::Assert(Simulator::outPort_test_paddle_ball_y->Cycle == Simulator::CurrentCycle);
    if (Simulator::outPort_test_paddle_ball_y->Value->GreaterThanOrEquals(Simulator::register_paddle_location_y->StoredValue))
    {
        this->Value_binaryexpression30 = Integer::One;
    }
    else
    {
        this->Value_binaryexpression30 = Integer::Zero;
    }
    if (Integer::Zero->NotEquals(this->Value_binaryexpression30))
    {
        this->Value_ternaryexpression34->ValueCopy(this->Constant_1);
    }
    else
    {
        this->Value_ternaryexpression34->ValueCopy(this->Constant_minus_1);
    }
    this->Value->ValueCopy(this->Value_ternaryexpression34);
        break;
      }

    /* Mark this entity as valid for this cycle  */
    this->Cycle = Simulator::CurrentCycle;
}

void Signal_paddle_sign_distance_y::Initialize(void)
{
    this->Value = new Integer(16, true);
    this->Value_binaryexpression30 = new Integer(1, false);
    this->Constant_1 = new Integer(2, "1", false);
    this->Constant_minus_1 = new Integer(3, "-1", true);
    this->Value_ternaryexpression34 = new Integer(3, true);
}

